//
// Created by xili on 2024/8/7 20:32.
// Go big or go home.
//
#include <vector>
#include <algorithm>

using namespace std;

class Solution {
public:
    int deleteGreatestValue(vector<vector<int>> &nums) {
        int n = nums.size();
        int m = nums[0].size();
        int ans = 0;
        for (int i = 0; i < n; i++) {
            sort(nums[i].begin(), nums[i].end());
        }
        for (int j = 0; j < m; j++) {
            int mx = 0;
            for (int i = 0; i < n; i++) {
                mx = max(mx, nums[i][j]);
            }
            ans += mx;
        }
        return ans;
    }
};